Skip to content

Indicator leds: make templatable for active high/low, give 3 interfaces; power, logic, analog#420

Draft
ruben-iteng wants to merge 7 commits intomainfrom
feature/indicator_leds_proper_connections
Draft

Indicator leds: make templatable for active high/low, give 3 interfaces; power, logic, analog#420
ruben-iteng wants to merge 7 commits intomainfrom
feature/indicator_leds_proper_connections

Conversation

@ruben-iteng
Copy link
Copy Markdown
Contributor

@ruben-iteng ruben-iteng commented Feb 13, 2026

Inheritance in ato is broken (see atopile/atopile#1698).

The factory is not called when using inheritance. Same related problems: atopile/atopile#1693 and atopile/atopile#1684


You can now do this 😎 -->

#pragma experiment("MODULE_TEMPLATING")

import ElectricPower

from "atopile/indicator-leds/indicator-leds.ato" import LEDIndicatorRed
from "atopile/indicator-leds/indicator-leds.ato" import LEDIndicatorGreen
from "atopile/indicator-leds/indicator-leds.ato" import LEDIndicatorBlue

module Usage:
    """
    Minimal usage example for `indicator-leds`.
    Demonstrates 3 connection options and 2 active states.
    """

    red_led_active_high = new LEDIndicatorRed<active_low=False> # by default, active high, so template is optional
    green_led_active_high = new LEDIndicatorGreen
    blue_led_active_high = new LEDIndicatorBlue
    red_led_active_low = new LEDIndicatorRed<active_low=True>
    green_led_active_low = new LEDIndicatorGreen<active_low=True>
    blue_led_active_low = new LEDIndicatorBlue<active_low=True>

    # Connect to power (active high or low does not matter, always on when power is on)
    power = new ElectricPower
    power.voltage = 5V +/- 5%
    power ~ red_led_active_high.power
    power ~ red_led_active_low.power

    # Or connect to logic signal
    logic = new ElectricLogic
    logic.reference ~ power
    logic ~ green_led_active_high.logic
    logic ~ blue_led_active_low.logic

    # Or connect to analog signal
    analog_signal = new ElectricSignal
    analog_signal.reference ~ power
    analog_signal ~ green_led_active_low.analog_signal
    analog_signal ~ blue_led_active_high.analog_signal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant